package demo2;

public class test1 {
    private boolean isNumber(char c) {
        if(!Character.isDigit(c)) {
            return false;
        }
        return true;
    }
    private boolean isAlf(char c) {
        if(!Character.isLetter(c)) {
            return false;
        }
        return true;
    }

    public boolean isPalindrome(String s) {
        String s1 = s.toLowerCase();
        int left = 0;
        int right = s1.length() - 1;
        while(left < right) {
            while(left < right && !isAlf(s1.charAt(left)) && !isNumber(s1.charAt(left))) {
                left++;
            }
            while(left < right && !isAlf(s1.charAt(right)) && !isNumber(s1.charAt(right))) {
                right--;
            }
            if(s1.charAt(left) != s1.charAt(right)) {
                return false;
            }else {
                left++;
                right--;
            }
        }
        return true;
    }

    public static void main(String[] args) {

    }
}
